﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Iguana.Core.HypterText
{

    /// <summary>
    /// Represents a basic HTML writer. Not specialized and should only be used for specific, simple tasks.
    /// </summary>
    public class BasicWriter
    {
        private Dictionary<string, string> m_Attributes;

        public Dictionary<string, string> Attributes
        {
            get { return m_Attributes; }
            set { m_Attributes = value; }
        }
        private string m_Start;

        public string Start
        {
            get { return m_Start; }
            set { m_Start = value; }
        }
        private string m_End;

        public string End
        {
            get { return m_End; }
            set { m_End = value; }
        }
        private string m_Content;

        public string Content
        {
            get { return m_Content; }
            set { m_Content = value; }
        }
        

        public BasicWriter()
        {
            m_Attributes = new Dictionary<string, string>();
            m_Start = m_End = m_Content = String.Empty;
        }

        public override string ToString()
        {
            StringBuilder m_Builder = new StringBuilder();
            m_Builder.Append(String.Format(SR.SR_ELEMENT_START_F, m_Start));

            foreach (var i in m_Attributes)
            {
               
                    m_Builder.Append(String.Format(SR.SR_ATTRIBUTE_NAME_VALUE_PAIR, i.Key, i.Value));
               
            }

            string m_Temp = m_Builder.ToString();
            m_Temp = m_Temp.TrimEnd(new char[] { ' ' });
            m_Temp = m_Temp + m_End;
            return m_Temp;
        }
    }
}
